//
//  BVIndexCell1.m
//  XiangYu
//
//  Created by YYKJ on 2017/6/2.
//  Copyright © 2017年 YYKJ. All rights reserved.
//

#import "BVIndexCell1.h"

@implementation BVIndexCell1

-(id)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        [self layoutUI];
    }
    return self;
}

-(void)layoutUI{
    
    //标题图标
    self.avatarImg = [[UIImageView alloc]init];
    [self.contentView addSubview:self.avatarImg];
    [self.avatarImg.layer setMasksToBounds:YES];
    [self.avatarImg.layer setCornerRadius:3.0];
    [self.avatarImg setContentMode:UIViewContentModeScaleAspectFill];
    self.avatarImg.sd_layout.
    topSpaceToView(self.contentView,0)
    .bottomSpaceToView(self.contentView,0)
    .leftSpaceToView(self.contentView,0)
    .rightSpaceToView(self.contentView, 0);
    [self.avatarImg setImage:[UIImage imageNamed:@"9358d"]];
    
    self.coverView = [[UIView alloc]init];
    [self.contentView addSubview:self.coverView];
    [self.coverView setBackgroundColor:COLOR_RGB(183, 0.0, 92.0, 0.5)];
    self.coverView.sd_layout
    .leftSpaceToView(self.contentView, 0)
    .rightSpaceToView(self.contentView, 0)
    .bottomSpaceToView(self.contentView, 0)
    .heightIs(60);
    
    self.nameLb = [[UILabel alloc]init];
    [self.coverView addSubview:self.nameLb];
    [self.nameLb setText:@"某某某"];
    [self.nameLb setTextColor:[UIColor whiteColor]];
    [self.nameLb setFont:[UIFont systemFontOfSize:14]];
    [self.nameLb setTextAlignment:NSTextAlignmentCenter];
    self.nameLb.sd_layout
    .topSpaceToView(self.coverView, 10)
    .leftSpaceToView(self.coverView, 0)
    .rightSpaceToView(self.coverView, 0)
    .heightIs(20);
    
    self.addressLb = [[UILabel alloc]init];
    [self.coverView addSubview:self.addressLb];
    [self.addressLb setText:@"郑州市金水区"];
    [self.addressLb setTextColor:[UIColor whiteColor]];
    [self.addressLb setFont:[UIFont systemFontOfSize:14]];
    [self.addressLb setTextAlignment:NSTextAlignmentCenter];
    self.addressLb.sd_layout
    .topSpaceToView(self.nameLb, 0)
    .leftSpaceToView(self.coverView, 0)
    .rightSpaceToView(self.coverView, 0)
    .heightIs(20);
    
}

-(void)setModel:(BVIndexModel *)model{
    
    [self.avatarImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",PATH,model.avatar512]] placeholderImage:[UIImage imageNamed:@"999k"]];
    [self.nameLb setText:model.nickname];
    [self.addressLb setText:[NSString stringWithFormat:@"%@-%@",model.city,model.district]];
    
    if ([model.sex isEqual:@"男"]) {
        [self.coverView setBackgroundColor:COLOR_RGB(183, 0.0, 92.0, 0.5)];
    }else{
        [self.coverView setBackgroundColor:COLOR_RGB(109, 175, 239, 0.5)];
    }
}

@end
